﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Drempelvrij.DAL.UnitOfWork;
using Drempelvrij.Models.Entities;
using NHibernate;
using Drempelvrij.DAL.SessionStorage;

namespace Drempelvrij.DAL.Repositories
{
    public class GeoDataRepository : Repository<GeoData, int>, IGeoDataRepository
    {
        public GeoDataRepository(IUnitOfWork uow)
            : base(uow)
        {
        }

        public GeoData findStraatViaLatLng(decimal lat, decimal lng)
        {
            ICriteria criteriaQuery = SessionFactory.GetCurrentSession()
                    .CreateCriteria(typeof(GeoData))
                    .Add(NHibernate.Criterion.Restrictions.Eq("lat", lat))
                    .Add(NHibernate.Criterion.Restrictions.Eq("lng", lng));

            return criteriaQuery.List<GeoData>().FirstOrDefault();
        }
    }
}
